package god.dream.notice.model;

import god.dream.user.model.User;

import java.sql.Date;

import org.apache.commons.lang.builder.EqualsBuilder;

public class Notice {
	private int id;
	private String title;
	private String content;
	private Date date;

	public Notice() {
	}

	public Notice(int id, String title, String content, String date) {
		this.id = id;
		this.title = title;
		this.content = content;
		this.date = Date.valueOf(date);
	}

	public Object[] insert() {
		return new Object[] { getId(), getTitle(), getContent(), getDateToDate() };
	}

	public Object[] update() {
		return new Object[] { getTitle(), getContent(), getDateToDate(), getId() };
	}
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Notice == false) {
			return false;
		}
		if (this == obj) {
			return true;
		}

		Notice notice = (Notice) obj;
		return new EqualsBuilder()
				.append(getId(), notice.getId())
				.append(getTitle(), notice.getTitle())
				.append(getDate(), notice.getDate())
				.append(getContent(), notice.getContent())
				.isEquals();
	}
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getDateToDate() {
		return date;
	}

	public String getDate() {
		if(date != null)
			return date.toString();
		return null;
	}

	public void setDate(String date) {
		this.date = Date.valueOf(date);
	}
}
